package com.yuanqi.Mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yuanqi.Common.Pojo.Vo.PostVo;
import com.yuanqi.Common.Pojo.entity.Post;
import com.yuanqi.Common.Pojo.entity.PostClass;
import com.yuanqi.Common.Pojo.entity.Support;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PostMapper extends BaseMapper<Post>{
    @Select("select id,classname  from post_class where status = 1")
    List<PostClass> selectclasslist();

    @Insert("insert into post_image(post_id, image_id,create_time) values (#{id},#{id1},#{time})")
    void saveImagePost(Integer id, Long id1,Long time);

    @Insert("insert into topic_post(post_id,topic_id,create_time) values (#{id},#{topicId},#{time})")
    void savePostTopic(Integer id, Integer topicId,Long time);

    List<String> selectImage(Integer id);


    List<PostVo> selectPostAndCommentCountByPostId(Long id, Integer start);
    @Select("select type ,COUNT(type) as count from support WHERE post_id = #{id}  GROUP BY type ")
    List<Support> selectSupport(Integer id);

    @Select("select type from support where user_id = #{userId} and post_id = #{id}")
    Integer selectUserSupport(Long userId, Integer id);

    List<PostVo> selectPostAndCommentCountByUserId(Long userid,Integer start,Integer isopen);

    List<PostVo> searchPostBytitle(String title, Integer start);

    @Select("select black_id from blacklist where user_id = #{userId}")
    List<Long> selectLaheiUserId(Long userId);

    @Select("select user_id from blacklist where black_id = #{userId}")
    List<Long> selectBeiLaheiUserId(Long userId);

    List<PostVo> getconcernpost(Integer start,Long userId);
}
